<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>赛马办公系统</title>
</head>
<link href="${ctx}/css/main/outer2.css" rel="stylesheet" type="text/css"/>
<link href="${ctx}/css/main/main.css" rel="stylesheet" type="text/css"/>
<body><div id="context">
<div id="top">
	<div class="logo"><img src="${ctx}/images/outer/logo.jpg" /></div>
	<div class="nav">
		<div class="menusel"><h2><a href="${ctx}/index.jsp">站点首页</a></h2></div>
		<div id="menu1" class="menusel">
		<h2><a href="#">赛事查询</a></h2>
		<ul class="clearfix typeul">
		<li><a href="${ctx}/front/raceSearch!searchRaceEntry.action">报名表</a></li>
		<li><a href="${ctx}/front/raceSearch!searchRaceSplit.action">宣布出赛</a></li>
		<li><a href="${ctx}/front/raceSearch!searchRaceManual.action">赛事手册</a></li>
		<li><a href="${ctx}/front/raceSearch!searchRaceResult.action">赛事结果</a></li>
		<li><a href="${ctx}/front/raceSearch!searchRaceCalendar.action">赛事日程</a></li>
		<li class="lli"><a href="${ctx}/front/raceSearch!searchRaceChange.action">赛事变更</a></li>
		</ul>
		</div>
		<div id="menu2" class="menusel">
		<h2><a href="#">马匹查询</a></h2>
		<ul class="clearfix typeul">
		<li><a href="${ctx}/front/horseSearch!searchHorse.action">马匹资料</a></li>
		<li><a href="${ctx}/front/horseSearch!searchHorseRating.action">马匹评分</a></li>
		<li><a href="${ctx}/front/horseSearch!searchHorseChange.action">马匹转厩</a></li>
		<li><a href="${ctx}/front/horseSearch!searchHorseRetire.action">马匹退役</a></li>
		<li><a href="${ctx}/front/horseSearch!searchNewHorseRating.action">新马评分</a></li>
		<li class="lli"><a href="${ctx}/front/horseSearch!searchHorseBonus.action">马匹奖金</a></li>
		</ul>
		</div>
		<div id="menu3" class="menusel">
		<h2><a href="#">骑练查询</a></h2>
		<ul class="clearfix typeul">
		<li><a href="${ctx}/front/jockey!searchJockey.action">骑师</a></li>
		<li class="lli"><a href="${ctx}/trainer/trainer!searchTrainer.action">练马师</a></li>
		</ul>
		</div>
		<div id="menu4" class="menusel">
		<h2><a href="${ctx}/loginindex.action">管理登录</a></h2>
		</div>
	</div><div class="bihe"></div>
	<script type="text/javascript" src="${ctx}/scripts/sys/outer_nav.js"></script>
</div>
<form  method="post" action="${ctx}/user/user_register.action" >
<table width="90%" border="0" cellspacing="0" cellpadding="0" class="tab_m left" style="border:#BEC9DE 1px solid">
  <tr>
    <td colspan="4" class="zctop left"><span class="font14 zc_bt">用户注册</span></td>
  </tr>
  <tr>
    <td width="20%" class="right">注册账号：</td>
    <td><input type="text"  name="user.userLogin" value="${user.userLogin}" class="fl_l"><span class="xing">*</span><div id="errLogin">${info }</div></td>
  </tr>
  <tr>
    <td class="right">登录密码：</td>
    <td><input type="password" name="user.userPwd" value="${user.userPwd}" class="fl_l"/><div id="errPsw1"></div></td>
  </tr>
  <tr>
    <td class="right">确认登录密码：</td>
    <td><input type="password"  name="userPwd" value="${userPwd}" class="fl_l"><div id="errPsw2"></div></td>
  </tr>
  <tr>
    <td class="right">姓名：</td>
    <td><input type="text" name="user.userName" value="${user.userName}" class="fl_l"/><span class="xing">*</span><div id="errName"></div></td>
  </tr>
  <tr>
    <td class="right">别名：</td>
    <td><input type="text" name="user.userAlias" value="${user.userAlias}" class="fl_l"/><div id="errAlias"></div></td>
  </tr>
  <tr>
    <td class="right">身份证号：</td>
    <td><input type="text" id="userCard"  name="user.userCard" value="${user.userCard}" onblur="showBirthday(document.all.userCard.value);" class="fl_l"/><div id="code"></div></td>
  </tr>
  <tr>
    <td class="right">性别：</td>
    <td>
    <select name="user.userSex">
                <option value="">--性别--</option>
                <option value="0" <s:if test="user.userSex == 0">selected</s:if> >男</option>
                <option value="1" <s:if test="user.userSex == 1">selected</s:if>>女</option>
                </select></td>
  </tr>
  <tr>
    <td class="right">生日：</td>
    <td><input type="text" name="user.userBirthday" id="birthday" value="" readonly="readonly"/>
     <img src="${ctx}/images/main/calendar.gif" align="absMiddle" border="0" style="cursor:hand" onclick="new WdatePicker(document.getElementById('birthday'),null,false,'whyGreen')">
    </td>
  </tr>
  <tr>
    <td class="right">手机号：</td>
    <td><input type="text" name="user.userPhone" value="${user.userPhone}" class="fl_l"/><div id="errPhone"></div></td>
  </tr>
  <tr>
    <td class="right">电子邮箱：</td>
    <td><input type="text" name="user.userEmail" value="${user.userEmail}" class="fl_l"/><div id="errEmail"></div></td>
  </tr>
  <tr>
    <td class="right">用户角色：</td>
    <td>
    <select name="user.roleId">
                <option value="">--角色--</option>
               <s:iterator value="baseroles" status="role">
                <option value="<s:property value="roleId"/>" <s:if test="user.roleId == roleId">selected</s:if> ><s:property value="roleName"/></option>
                </s:iterator>
                </select>
    </td>
  </tr>
  <tr>
    <td class="right">所在部门：</td>
    <td>
    <select name="user.deptId">
                <option value="" >--部门--</option>
               <s:iterator value="departments" status="depart">
                <option value="<s:property value="deptId"/>" <s:if test="user.deptId == deptId">selected</s:if> >${deptNames}</option>
                </s:iterator>
                </select>
    </td>
  </tr>
  <tr>
    <td class="right">备注：</td>
    <td><textarea name="user.userMemo" class="zc_textarea" class="fl_l"></textarea></td>
  </tr>
  <tr>
    <td colspan="2" class="hei_1 center"><input  type="button" onclick="registerUser();" value="提 交" class="log_f zc_b">
	<input type="reset" value="重 置" class="log_f zc_b">
	<input type="button" value="返 回" class="log_f zc_b" onClick="javascript:window.location = '${ctx}/loginindex.action';"></td>
  </tr>
</table>
<br/>
</form>
</div>
<div id="footer"><s:text name="index.copy" /></div>
</body>
</html>

<script type="text/javascript" src="${ctx}/scripts/commons/validation.js"></script>
<script src="${ctx}/scripts/datepicker/WdatePicker.js"></script>
<script type="text/javascript">
<!--
function registerUser(){
var userLogin = document.getElementById("user.userLogin").value;
var password1 = document.getElementById("user.userPwd").value;
var password2 = document.getElementById("userPwd").value;
var userName = document.getElementById("user.userName").value;
var userAlias = document.getElementById("user.userAlias").value;
var userCard = document.getElementById("user.userCard").value;
var userPhone = document.getElementById("user.userPhone").value;
var userEmail = document.getElementById("user.userEmail").value;

if(userLogin.length == 0){
document.getElementById("errLogin").innerHTML = "<font color='red'> 帐号不能为空!</font>";
return false;
}
if(hasSpecialChart(userLogin)){
document.getElementById("errLogin").innerHTML = "<font color='red'> 帐号不能有特殊字符!</font>";
return false;
}
if(userLogin.length > 20){
document.getElementById("errLogin").innerHTML = "<font color='red'> 帐号长度不能大于20!</font>";
return false;
}
if(userLogin.length > 20){
document.getElementById("errLogin").innerHTML = "<font color='red'> 帐号长度不能大于20!</font>";
return false;
}
if(password1.length != 0 && password2.length == 0){
document.getElementById("errPsw2").innerHTML = "<font color='red'> 需要确认输入密码!</font>";
return false;
}
if(password1.length != 0 && password2.length != 0 && password1 != password2){
document.getElementById("errPsw2").innerHTML = "<font color='red'> 两次输入密码不一致!</font>";
return false;
}
if(userAlias.length > 20){
document.getElementById("errAlias").innerHTML = "<font color='red'> 别名长度不能大于20!</font>";
return false;
}
if(userAlias.length > 0 && hasSpecialChart(userAlias)){
document.getElementById("errAlias").innerHTML = "<font color='red'> 别名不能有特殊字符!</font>";
return false;
}
if(userName.length == 0){
document.getElementById("errName").innerHTML = "<font color='red'> 用户姓名不能为空!</font>";
return false;
}
if(userName.length > 0 && hasSpecialChart(userName)){
document.getElementById("errName").innerHTML = "<font color='red'> 用户姓名不能有特殊字符!</font>";
return false;
}
if(userName.length > 20){
document.getElementById("errName").innerHTML = "<font color='red'> 用户姓名长度不能大于20!</font>";
return false;
}
if(code.length > 0 && !(/^\d{18}|\d{17}[xX]{1}|\d{15}$/).test(code)){
	document.getElementById("code").innerHTML = "<font color='red'> 请正确输入身份证号码!</font>";
	return false;
}
if(userPhone.length > 20){
document.getElementById("errPhone").innerHTML = "<font color='red'> 手机号码长度不能大于20!</font>";
return false;
}
if(userPhone.length > 0 && !isAllNumber(userPhone)){
	document.getElementById("errPhone").innerHTML = "<font color='red'> 正确填写手机号码!</font>";
	return false;
}
if(userEmail.length > 50){
document.getElementById("errEmail").innerHTML = "<font color='red'> 电子邮箱长度不能大于50!</font>";
return false;
}
if(userEmail.length > 0 && isEmail(userEmail) == false){
	document.getElementById("errEmail").innerHTML = "<font color='red'> 正确填写电子邮箱!</font>";
	return false;
}
document.getElementById("errLogin").innerHTML ="";
document.getElementById("errPsw2").innerHTML ="";
document.getElementById("errName").innerHTML ="";
document.getElementById("code").innerHTML ="";
document.getElementById("errPhone").innerHTML ="";
document.getElementById("errEmail").innerHTML ="";
document.forms[0].submit();

}

//根据身份证，获得性别和出生年月
　　 function showBirthday(val)
　　 {
 	if((/^\d{18}|\d{17}[xX]{1}|\d{15}$/).test(val)){

		var birthdayValue;
	　　 if(15==val.length)
	　　 { //15位身份证号码
	　　 birthdayValue = val.charAt(6)+val.charAt(7);
	　　 if(parseInt(birthdayValue)<10)
	　　 {
	　　 birthdayValue = '20'+birthdayValue;
	　　 }
	　　 else
	　　 {
	　　 birthdayValue = '19'+birthdayValue;
	　　 }
	　　 birthdayValue=birthdayValue+'-'+val.charAt(8)+val.charAt(9)+'-'+val.charAt(10)+val.charAt(11);
	　　 if(parseInt(val.charAt(14)/2)*2!=val.charAt(14))
	    document.getElementById("user.userSex").value=0;
	    else
		document.getElementById("user.userSex").value=1;
		document.getElementById("user.userBirthday").value= birthdayValue;
	　　 }
	　　 if(18==val.length)
	　　 { //18位身份证号码
	　　 birthdayValue=val.charAt(6)+val.charAt(7)+val.charAt(8)+val.charAt(9)+'-'+val.charAt(10)+val.charAt(11) 
	　　 +'-'+val.charAt(12)+val.charAt(13);
	　　 if(parseInt(val.charAt(16)/2)*2!=val.charAt(16))
	    document.getElementById("user.userSex").value=0;
	    else
		 document.getElementById("user.userSex").value=1;
	　　 document.getElementById("user.userBirthday").value= birthdayValue;
	　　 }
	}else{
		document.getElementById("code").innerHTML = "<font color='red'> 请正确输入身份证号码!</font>";
	}
　　 }

//-->
</script>